<?php
//$_POST['text']=' ';
/*echo mktime(0,0,0,2,0,2017);
echo '<br/>';
echo date('Y-m-d',mktime(0,0,0,1,1,2017));
$month=1;
$year=2017;
$qi=mktime(0,0,0,$month,1,$year);
$zhong=mktime(0,0,0,$month+1,1,$year);

echo date('Y-m-d',$qi);
echo "<br/>";
echo date('Y-m-d',$zhong);*/





//echo "SELECT title FROM wenzhang WHERE text LIKE  '%$u%'";

//var_export($o);


//模糊搜索的
$u=addslashes(trim($_POST['text']));
//var_export($u);
$info=array();
//var_export($g);
if (empty($_POST['text']))
{
    $info[]='ha';
    echo json_encode($info);
    exit;
}
$o=$oMysql->get("SELECT title,pubdate,id  FROM wenzhang WHERE CONCAT( IFNULL( title, '' ) , IFNULL( text, '' ) ) LIKE  '%$u%'");
//echo "SELECT title,pubdate,text  FROM wenzhang WHERE CONCAT( IFNULL( title, '' ) , IFNULL( text, '' ) ) OR title LIKE  '%$u%'";

for ($i=0;$i<count($o);$i++)
{
    $info[$i]=$o[$i];
}
for ($i=0;$i<count($info);$i++)
{
    $info[$i]['pubdate']=date('Y-m-d',$info[$i]['pubdate']);
}
echo json_encode($info);

//var_export($info);

//echo "SELECT title FROM wenzhang WHERE pubdate>=$qi AND pubdate<$zhong";
//var_export($info);